import 'babel-polyfill';
// import 'es6-promise/auto';
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import App from './App.vue';
import router from './router';
import store from './store';
import apiConstants from "./api/constants";
import { messages } from '@common/components/common/i18n';
import utils from '@common/utils/utils';
import '@common/plugins';
import CommonDialog from '@common/components/dialog';

Vue.prototype.$api = apiConstants;
Vue.use(CommonDialog, store, router);
const i18n = new VueI18n({
	locale: 'zh-CN',
	messages
});
//使用钩子函数对路由进行权限跳转
router.beforeEach(async (to, from, next) => {
	// 公共路由处理
	let routes = router.options.routes;
	let valid = await utils.procRouter(to, from, next, store, routes);
	if (valid) {
		// 可自定义处理路由
		next();
	}
});
new Vue({
	store,
	router,
	i18n,
	render: h => h(App)
}).$mount('#app');
